#include <QString>
#include <QList>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <SMTData.h>
#include <SMTGUI.h>

namespace aoi
{
	typedef QVector<QVector<float>> RegisterMatrix;

	class ExtraParams
	{
	public:
		QString extra_name;
		QString extra_name2;
	};
	class ReqFile
	{
	public:
		QString fileName;
		QString	imageData;
		ReqFile();
		ReqFile(QString fileName, QString imageData);
	};

	class GlobalThresh
	{
	public:
		float confThresh = 0;
		QString overlapMetric = "IOU";
		float overlapThresh = 0;
		GlobalThresh();
		GlobalThresh(float confThresh, QString overlapMetric, float overlapThresh);
	};

	class LabelSpecThresh
	{
	public:
		QString label;
		float confThresh = 0;
		QString overlapMetric = "IOU";
		float overlapThresh = 0;
		LabelSpecThresh();
		LabelSpecThresh(QString label, float oneConfThresh, QString overlapMetric, float overlapThresh);
	};

	class MatchParams
	{
	public:
		GlobalThresh globalThresh;
		QList<LabelSpecThresh> labelSpecThreshList;
	};

	class Pattern
	{
	public:
		QString label;
		int height;
		int width;
		int X;
		int Y;
		float confThresh = 0;
		QString detailLabel;
		int numMatch;
		QString overlapMetric = "IOU";
		int overlapThresh;
		QString reserved1;
		QString reserved2;
		QString reserved3;
		QString reserved4;
		QString reserved5;
		QString reserved6;

		Pattern();
		Pattern(QString label,
			int width,
			int height,
			int X,
			int Y,
			float confThresh,
			QString detailLabel,
			int numMatch,
			QString overlapMetric,
			int overlapThresh);
	};

	class Roi {
	public:
		int X;
		int Y;
		int height;
		int width;
		QString type;
		Roi();
		Roi(int x,
			int y,
			int width,
			int height,
			QString type);
	};

	class AoiReq
	{
	public:
		QString projectName;
		QString taskName;
		QString taskType;
		QString cameraId;
		QString machineId;
		QString productCode;
		QString tableName;
		QString codeType;
		QList<Roi> rois;
		RegisterMatrix registerMatrix;
		ExtraParams extraParams;
		QList<ReqFile> reqFiles;
		MatchParams matchParams;
		QList<Pattern>  patterns;

		QJsonDocument toQJsonDocument();

		QByteArray toJsonQByteArray();

		QString toJsonQString();
	};
}

